#ifndef __UTILS_H__
#define __UTILS_H__

#ifdef __cplusplus
extern "C" {
#endif

/*
 * for string
 */
int trim_right(char * buf);

/*
 * for file && shell
 */
int get_one_line_from_file(const char * file_name, char * buf);

int get_data_from_file(const char * file_name, const char *pattern, char * buf);

int popen_cmd(const char * cmd, char * buf, int max_buf_len);

int popen_cmd_no_buf(const char * cmd);

/*
 * for net
 */
int get_ifreq(char * inf, int siogifcmd, struct ifreq * ifr);

int get_if_sockaddr(char * inf, int siocgif_xxx, char * buf);

int get_if_mac(char * inf, char * mac);

int get_if_proto(char * inf, int * proto);

int get_if_flag(char * inf, unsigned int *flag);

int is_valid_netmask(unsigned char * netmask);

int is_valid_ip(unsigned char * ip);

#ifdef __cplusplus
}
#endif

#endif
